package com.woniu.tms.openclass.service.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.woniu.tms.entity.Classes;
import com.woniu.tms.entity.ClassesExample;
import com.woniu.tms.entity.ClassesExample.Criteria;
import com.woniu.tms.entity.UserRole;
import com.woniu.tms.mapper.ClassesMapper;
import com.woniu.tms.openclass.service.openClassService;

@Service
public class openClassServiceImpl implements openClassService{
    @Autowired
	  ClassesMapper classesMapper;
	
	@Override
	public List<Classes> findByRnameLike(String rnameLike) {
		   ClassesExample example=new ClassesExample();
		   Criteria criteria = example.createCriteria();
		   criteria.andCnameLike("%"+rnameLike+"%");
		   List<Classes> classesList = classesMapper.selectByExample(example);
		   return classesList;
	}

	@Override
	public void add(Classes classes) {
		classesMapper.insert(classes);
		
	}

	@Override
	public void delete(Integer[] cid) {
		ClassesExample example=new ClassesExample(); 
		Criteria criteria = example.createCriteria();
		criteria.andCidIn(Arrays.asList(cid));
		classesMapper.deleteByExample(example);
	}



	@Override
	public List<Classes> findByUids(Integer uid) {
		
		   ClassesExample example=new ClassesExample();
		   Criteria criteria = example.createCriteria();
		   criteria.andClassmanageridEqualTo(uid);
		   List<Classes> classesList = classesMapper.selectByExample(example);
		return classesList;
	}

	@Override
	public void findByUid() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Classes> findByUid(Integer uid) {
		ClassesExample example=new ClassesExample();
		   Criteria criteria = example.createCriteria();
		   criteria.andTeacheridEqualTo(uid);
		   List<Classes> classesList = classesMapper.selectByExample(example);
		return classesList;
		
	}

}
